package com.xinghou.platform.server.api.controller;

import com.xinghou.platform.entity.req.ListReq;
import com.xinghou.platform.model.main.Meiji;
import com.xinghou.platform.model.main.MeijiWaterfall;
import com.xinghou.platform.service.main.MeijiService;
import com.xinghou.platform.util.StringUtils;
import com.xinghou.platform.util.exception.DBExceptionEnums;
import com.xinghou.platform.util.exception.ServiceException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * Created by liufangyu on 16/8/30.
 */
@Controller
@SessionAttributes("token")
public class MeijiController extends  BaseControl {
    @Resource
    public MeijiService meijiService;


    /**
     * 美记list
     * @param listReq
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/meiji",method = {RequestMethod.POST})
    public String notice( @RequestBody ListReq listReq,
                          HttpServletRequest request, HttpServletResponse response)
    {
    /*    if (StringUtils.isBlank(requestContent.get("uasystem")))
            throw new ServiceException(DBExceptionEnums.UA_SYSTEM_US_NULL);*/
        List<Meiji> list = meijiService.meijiList(listReq);

        return response(list);
    }

    /**
     * 瀑布流
     * @param listReq
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/waterfall",method = {RequestMethod.POST})
    public String getSubjects( @RequestBody ListReq listReq,
                               HttpServletRequest request, HttpServletResponse response)
    {
        List<MeijiWaterfall> list = meijiService.waterfallList(listReq);
        return response(list);

    }

    /**
     * 美记Detail
     * @param listReq
     * @param request
     * @param response
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/meijiDetail",method = {RequestMethod.POST})
    public String meijiDetail( @RequestBody ListReq listReq,
                          HttpServletRequest request, HttpServletResponse response)
    {
        if (StringUtils.isBlank(listReq.getId()))
            throw new ServiceException(DBExceptionEnums.PRARM_ERROR);

        return response(meijiService.meijiDetail(Integer.parseInt(listReq.getId())));

    }

}
